<style lang="scss" scoped>
@import '../../style/mixin-rem.scss';
.book-case-content-item {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: rem(26px);
  background-color: #fff;
  color: #bbb;
  .hot {
    // 热点
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }
  .cover {
    // 小说封面
    width: rem(108px);
    border-radius: rem(6px);
  }
  .intro {
    // 简介
    padding-left: rem(26px);
  }
  .title {
    // 标题
    margin-bottom: rem(16px);
    font-size: rem(30px);
    color: #42464e;
  }
  .author {
    // 作者
    margin-bottom: rem(16px);
    font-size: rem(24px);
  }
  .chapter {
    // 章节
    font-size: rem(24px);
  }
  .del-hot {
    // 删除
    position: absolute;
    top: 0;
    right: rem(-40px);
    width: rem(80px);
    height: rem(80px);
    display: flex;
    justify-content: center;
  }
  .icon-lajitong {
    font-size: rem(18px);
  }
}
</style>

<template>
  <div class="book-case-content-item">
    <div class="hot" @click="toReader(index)">
      <img class="cover" :src="cover">
      <div class="intro">
        <div class="title" v-text="title"></div>
        <div class="author" v-text="author"></div>
        <div class="chapter" v-text="chapter"></div>
      </div>
    </div>
    <div class="del-hot" @click="getDelItemIndex(index)">
      <div class="iconfont icon-lajitong"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'bookCaseContentItem',
  props: {
    index: { type: Number, default: 0 },
    title: { type: String, default: '' },
    author: { type: String, default: '' },
    chapter: { type: String, default: '' },
    cover: { type: String, default: '' }
  },
  methods: {
    toReader (index) {
      this.$store.commit('bookCase/changeItemIndex', index)
      let id = this.$store.state.bookCase.content[0].id
      let chapterId = this.$store.state.bookCase.content[0].chapterId
      this.$router.push({ name: 'bookReader', params: { id: `wapbook-${id}-${chapterId}` } })
    },
    getDelItemIndex (index) {
      this.$store.commit('bookCase/delActionSheetShow')
      this.$store.commit('bookCase/getDelItemIndex', index)
    }
  }
}
</script>
